//
//  MainViewController.m
//  BombAbility
//
//  Created by oscar chinellato on 28/02/10.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "MainViewController.h"
#import "GameViewController.h";

@implementation MainViewController


@synthesize currentController;
@synthesize loginController;
@synthesize resumeController;
@synthesize gameController;
@synthesize user;


/*
 // The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
        // Custom initialization
    }
    return self;
}
*/

-(void)startResumeScreen:(id)sender {
	
	NSLog(@"startResumeScreen : inizio caricamento schermata di resume");
	
	ResumeViewController *rvc = [[ResumeViewController alloc] initWithNibName:@"Resume" bundle:[NSBundle mainBundle]];
	NSLog(@"Inizializzato controller resume");
	assert(rvc != nil);
	
	self.resumeController = rvc;
	
	self.currentController = rvc;
	
	[rvc setMainController:self];
	
	[rvc release];
	
	NSLog(@"cambiamento view a resume");
	
	[self.view addSubview:[rvc view]];
	
}


-(void)startRegistrationScreen:(id)sender {
	
	NSLog(@"startRegistrationScreen");

	if([sender isKindOfClass:[LoginViewController class]]) {
		
		[sender setView:[sender registrationView]];
		
		[self.view addSubview:[sender view]];
		
	}
}



-(void)startGameScreen:(id)sender {
	
	NSLog(@"startGameScreen : inizio caricamento schermata di resume");
	
	GameViewController *gvc = [[GameViewController alloc] initWithNibName:@"Game" bundle:[NSBundle mainBundle]];
	NSLog(@"Inizializzato controller game");
	assert(gvc != nil);
	
	self.gameController = gvc;
	
	self.currentController = gvc;
	
	[gvc release];
	
	NSLog(@"cambiamento view a game");
	
	
	[self.view addSubview:[gvc view]];
	
}


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
	
	NSLog(@"Inizio caricamento loginViewController");
	
	LoginViewController *lvc = [[LoginViewController alloc] initWithNibName:@"Login" bundle:[NSBundle mainBundle]];
	
	self.loginController = lvc;
	
	self.currentController = lvc;
	
	lvc.mainController = self;
	
	NSLog(@"LoginViewController caricato");
	
	[lvc release];
	[lvc setView:[lvc loginView]];
	
	[self.view addSubview:[lvc view]];
	
	
    [super viewDidLoad];
}


/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/



- (void)didReceiveMemoryWarning {
	// Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
	
	// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
	// Release any retained subviews of the main view.
	// e.g. self.myOutlet = nil;
}


- (void)dealloc {
    [super dealloc];
}


@end
